package com.mercury.ec.module.air.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import com.mercury.ec.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 机票订单客票状态枚举
 *
 * @author hesx
 */
@Getter
@AllArgsConstructor
public enum AirOrderTicketStatusEnum implements IntArrayValuable {

    WAIT_TICKET(0, "待出票"),
    TICKETING(1, "出票中"),
    TICKETED(2, "已出票"),
    TICKET_FAIL(3, "出票失败"),
    ;


    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AirOrderTicketStatusEnum::getStatus).toArray();

    public static final String DICT_TYPE = "air_order_ticket_status";

    /**
     * 值
     */
    private final Integer status;
    /**
     * 名称
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static AirOrderTicketStatusEnum getByStatus(int status) {
        return ArrayUtil.firstMatch(o -> o.getStatus().equals(status), values());
    }

    public static boolean isWaitTicket(Integer status) {
        return ObjUtil.equal(WAIT_TICKET.status, status);
    }

    public static boolean isTicketing(Integer status) {
        return ObjUtil.equal(TICKETING.status, status);
    }

    public static boolean isTicketed(Integer status) {
        return ObjUtil.equal(TICKETED.status, status);
    }
    public static boolean isTicketFail(Integer status) {
        return ObjUtil.equal(TICKET_FAIL.status, status);
    }
}
